<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>账号配置</title>
    <script src="../editer-service/js/init.js?from=antd"></script>
    <style>
        #app{
            width: 800px;
            margin: auto;
        }
    </style>
</head>
<body>
<div id="app">
    <a-card title="自定义设置" style="width:100%;">
        <a-form-model layout="horizontal" :model="form" :label-col="{ span: 6 }" :wrapper-col="{ span: 12 }">
            <a-form-model-item label="密码" prop="password">
                <a-input v-model="form.password" placeholder="请输入密码" type="text" />
            </a-form-model-item>
            <a-form-model-item label="自动保存" prop="save">
                <a-switch v-model="form.save"></a-switch>
            </a-form-model-item>
            <a-form-model-item v-if="form.save" label="时间间隔(秒)" prop="sv">
                <a-input-number v-model="form.sv" :min="5" :max="600"></a-input-number>
            </a-form-model-item>
            <a-form-model-item label="显示提示" prop="canShow">
                <a-switch v-model="form.canShow"></a-switch>
            </a-form-model-item>
            <a-form-model-item label="阿里云盘账号" prop="aliyun">
                <a-row>
                    <a-col span="16">
                        <a-radio-group :value="form.aliyun" @change="(e)=>{this.form.aliyun = e.target.value;}">
                            <a-radio-button value="default">
                                默认账号
                            </a-radio-button>
                            <a-radio-button value="me">
                                自定义账号
                            </a-radio-button>
                        </a-radio-group>
                    </a-col>
                    <a-col span="2"></a-col>
                    <a-col span="6">
                        <a v-if="form.aliyun == 'me'" target="_blank" href="../editer-service/setting.html">去配置账号</a>
                    </a-col>
                </a-row>

            </a-form-model-item>
            <a-form-model-item :wrapper-col="{ span: 18, offset: 10 }">
                <a-button type="primary" @click="saveConfig()">
                    保存
                </a-button>
            </a-form-model-item>
        </a-form-model>
    </a-card>
</div>
</body>
<script>
    Vue.app({
        data:{
            form:{
                save:false,
                sv:5,
                aliyun:"default",
                password:"",
                canShow:false
            }
        },
        methods: {
            saveConfig:function(){
                utils.delLocalStorage("controllerUrl");
                utils.$.post("/action.php?type=1",this.form,function (res){
                    utils.$.successMsg(res.msg);
                });
            },
            getConfig:function (){
                var that = this;
                utils.$.get("/action.php?type=0",function (res){
                    if(res.flag){
                        that.form = res.data;
                    }
                },true);
            },
            initData:function (){
                var path = window.location.origin + window.location.pathname;
                var pathSz = path.split("/");
                pathSz.length = pathSz.length-2;
                path = pathSz.join("/");
                utils.ajaxHost = path + "/php";
                this.getConfig();
            }
        },
        mounted:function(){
            this.initData();
        }
    });
</script>
</html>